<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="Cache-Control" content="no-cache"/>
    <meta http-equiv="Cache-Control" content="no-store"/>
    <meta http-equiv="Expires" content="0"/>
    <link rel="shortcut icon" type="image/x-icon" th:href="@{/static/favicon2.ico}">
    <link rel="stylesheet" th:href="@{/static/plugins/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/static/css/layout.css}">
    <link rel="stylesheet" th:href="@{/static/css/common.css}">
    <style>
        .page-content {
            padding: 10px;
        }

        a {
            color: cornflowerblue;
        }

        .must:after {
            content: "*";
            color: red;
        }

        a:hover {
            color: blue;
        }
    </style>
</head>
<body>
<div class="page-content">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label must">交班时间</label>
            <div class="layui-input-block">
                <input type="text" name="handOverTime" class="layui-input" id="time">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label must">交班人</label>
            <div class="layui-input-block">
                <input type="hidden" name="orgId" th:value="${session.organization.id}" autocomplete="off">
                <textarea name="handOverNames" placeholder="请输入交班人，多个请用逗号隔开" maxlength="200" class="layui-textarea"
                          lay-verify="required" autocomplete="off"></textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注事项</label>
            <div class="layui-input-block">
                <textarea name="remark" placeholder="请输入需要备注的事项" maxlength="450" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formsb">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

</div>
<script th:src="@{/static/plugins/jquery.js}"></script>
<script th:src="@{/static/plugins/layui/layui.js}"></script>
<script th:src="@{/static/js/common.js}"></script>
<script>
    //一般直接写在一个js文件中
    layui.use(['element', 'form', 'laydate'], function () {
        var $ = layui.jquery
            , layer = layui.layer
            , form = layui.form,
            laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#time' //指定元素
            ,type: 'datetime'
            ,value: new Date()
        });

        form.on('submit(formsb)', function (data) {
            console.log();
            $.ajax({
                url: '/handover/save',
                data: data.field,
                type: 'post',
                dataType: 'json',
                async: false,
                success: function (rs) {
                    if (rs.code === 200) {
                        parent.layer.close(parent.oo);
                        parent.location.reload();
                    } else {
                        layer.msg(rs.message);
                    }
                }
            });

            return false;
        });

    });
</script>
</body>

</html>